package com.totoro.tygeneratedragonblock.enums;

import com.totoro.tygeneratedragonblock.constants.ComputeTypeConst;
import com.totoro.tygeneratedragonblock.executor.computeparse.ComputeParseExecutor;
import com.totoro.tygeneratedragonblock.executor.computeparse.impl.DefaultComputeParseExecutor;
import com.totoro.tygeneratedragonblock.executor.computeparse.impl.ProbabilityComputeParseExecutor;
import com.totoro.tygeneratedragonblock.executor.computeparse.impl.RandomComputeParseExecutor;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.Bukkit;

/**
 * @author Totoro
 * @version 0.1.0
 * @date 2025/8/10 - 22:50
 * @description 标签执行器枚举
 **/
@AllArgsConstructor
@Getter
public enum ComputeExecutorEnum {
    EXPRESSION_COMPUTE_EXECUTOR(ComputeTypeConst.EXPRESSION, new DefaultComputeParseExecutor()),
    RANDOM_COMPUTE_EXECUTOR(ComputeTypeConst.RANDOM, new RandomComputeParseExecutor()),
    PROBABILITY_COMPUTE_EXECUTOR(ComputeTypeConst.PROBABILITY, new ProbabilityComputeParseExecutor());

    private final String computeType;
    private final ComputeParseExecutor computeParseExecutor;

    public static ComputeExecutorEnum getComputeExecutorEnum(String computeText) {
        for (ComputeExecutorEnum value : ComputeExecutorEnum.values()) {
            if(computeText.startsWith(value.getComputeType())) {
                return value;
            }
        }
        return EXPRESSION_COMPUTE_EXECUTOR;
    }

}
